package my.pack.tm;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;

public class ChooseLvl extends Activity{

	Spinner spinner;
	Button play, back;
	String level="1";
	 public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.choose);
	        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
	        
            spinner = new Spinner (this);
            spinner = (Spinner) findViewById(R.id.spinner);
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.level_array, android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(adapter);
          
            spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
	        play = new Button(this);
	        back = new Button(this);
	        play = (Button)findViewById(R.id.startB);
	        back = (Button)findViewById(R.id.backB);
	        
	        play.setOnClickListener(new View.OnClickListener() {  
				
				public void onClick(View v) {
					Intent intent=new Intent();
					intent.putExtra("level", level);
					intent.setClass(ChooseLvl.this, DisplayImg.class);  
					startActivityForResult(intent, 2); 
					
				}
			});
	        
	        back.setOnClickListener(new View.OnClickListener() {  
				
				public void onClick(View v) {         
					finish();  
				}
			});
	 }
	 //------------------------------------------------------------------------
	 public class MyOnItemSelectedListener implements OnItemSelectedListener {

		 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
			 level=parent.getItemAtPosition(pos).toString();
}

		 public void onNothingSelected(AdapterView<?> parent) {
		
	}
}
	 //-------------------------------------------------------------------------
}
